<?php  $void = $paymentForm->getObject()->getDocument()->getVoid(); ?>
<div id="<?php echo sfConfig::get('app_windows_payment_form_id')?>">
<?php if ($void=='N'):?>
<div class="form_title">Edit <?php echo $transaction_type?> Payment for <?php echo $paymentForm->getObject()->getListName() ?></div>
<?php else:?>
<div class="form_title">View <?php echo $transaction_type?> Payment for <?php echo $paymentForm->getObject()->getListName() ?>, PAYMENT IS VOID.</div>
<?php endif;?>
<?php  echo form_tag_for($paymentForm,'payment/update',array('id'=>'formPayment',))?>
  <font color="#FF0000"><?php echo $error_message;?></font>
  <table>
    <tr>
      <td class="container box">
          <?php include_partial('payment_form',array('documentForm'=>$documentForm,'paymentForm'=>$paymentForm,'transaction_type'=>$transaction_type,))?>
      </td>
      <?php if($transaction_type=='CHECK'):?>
      <td class="container box">
        <div class="separator">Check Payments</div>
        <div id="ajPaymentChecksPanel">
        <?php include_partial('payment_checks_grid',array('paymentCheckss'=>$paymentCheckss,'payment_iden'=>$paymentForm->getObject()->getPaymentIden(),'message'=>'','void'=>$void,))?>
        </div>
      </td>
      <?php endif;?>
      <td class="container box">
        <div class="separator">Invoices Paid</div>
        <div id="ajPaymentInvoicePanel">
        <?php 
          include_partial(
            'payment_invoice_grid',
            array(
              'paymentInvoices'=>$paymentInvoices,
              'payment_iden'=>$paymentForm->getObject()->getPaymentIden(),
              'customer_iden'=>$paymentForm->getObject()->getCustomerIden(),
              'total_payment'=>$paymentForm->getObject()->getTotalPayment(),
              'message'=>'',
              'void'=>$void,
            )
          )
        ?>
        </div>
      </td>
    </tr>
  </table>
  <?php if($void == 'N'):?>
  <center>
    <input type="submit" value="Save"/> | 
    <input type="reset" value="Reset"/> |
    <input type="button" value="Void" id="buttonVoidPayment"/>
  </center>
  <?php endif;?>
</form>
</div>

<?php if($void == 'N'):?>
<script language="javascript">
  $(document).ready(
    function(){
      paymentGetGridRowData('<?php echo $paymentForm->getObject()->getPaymentIden()?>');
      $("#formPayment").submit(
        function(){
          showStatusWindow();
      
          $(this).ajaxSubmit(
            {
              type: 'post',
              dataType: 'html',
              success: 
                function(data,statusText){
                  $('#ajPaymentPanel').html(data);
                  paymentGetGridRowData('<?php echo $paymentForm->getObject()->getPaymentIden()?>');
                  hideStatusWindow();
                },
            }
          );
          return false;
        }
      );
  
      $('#buttonVoidPayment').click(
        function(){
          $.get(
            'actionVerifier/verify',
            {
              'task':'paymentVoid',
              'payment_iden':"<?php echo $paymentForm->getObject()->getPaymentIden()?>",
              'callback':'paymentVoidSuccess',
              'cancel_callback':'paymentVoidSuccess({"payment_iden":"<?php echo $paymentForm->getObject()->getPaymentIden()?>"},\'\')',
              'prompt':"Void Payment# <?php echo $paymentForm->getObject()->getPaymentId()?>",
            },
            function(content){
              $('#ajPaymentPanel').html(content);
            }
          );
        }
      );
    }
  );
</script>
<?php endif;?>